Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support embedded go_proto_library #5567

Closed

Conversation

tingilee
Copy link
Contributor

@tingilee tingilee commented Oct 30, 2023

Checklist

  • I have filed an issue about this change and discussed potential changes with the maintainers.
  • I have received the approval from the maintainers to make this change.
  • This is not a stylistic, refactoring, or cleanup change.

Please note that the maintainers will not be reviewing this change until all checkboxes are ticked. See
the Contributions section in the README for more
details.

Discussion thread for this change

Issue number: #5566

Description of this change

Support embedded go_proto_library as source files in the same Go package.

With this change, proto refers to the pb.go as source files which is what we intend to do:

cat bazel-bin/proto/proto-106940904.intellij-info.txt
build_file_artifact_location {
  is_external: false
  is_source: true
  relative_path: "proto/BUILD.bazel"
  root_execution_path_fragment: ""
}
deps {
  dependency_type: 0
  target {
    label: "//proto:fooproto_go_proto"
  }
}
go_ide_info {
  import_path: "github.com/bazelbuild/intellij/examples/go/with_proto/proto"
  sources {
    is_external: false
    is_source: true
    relative_path: "proto/translators.go"
    root_execution_path_fragment: ""
  }
  sources {
    is_external: false
    is_source: false
    relative_path: "proto/fooproto_go_proto_/github.com/bazelbuild/intellij/examples/go/with_proto/proto/fooserver.pb.go"
    root_execution_path_fragment: "bazel-out/darwin_arm64-fastbuild/bin"
  }
}
key {
  label: "//proto:proto"
}
kind_string: "go_library"

@github-actions github-actions bot added product: GoLand GoLand plugin awaiting-review Awaiting review from Bazel team on PRs labels Oct 30, 2023
@iancha1992 iancha1992 linked an issue Oct 30, 2023 that may be closed by this pull request
@agluszak
Copy link
Collaborator

agluszak commented Nov 6, 2023

Hi! Thanks @tingilee for your contribution. Could you please write a test for this?

sha256 = "825c30d2cbcce405fd18fddf356eb1f425607e9c780f8eff95d21ac23f8d90fd",
url = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/231.8770.65/PythonCore-231.8770.65.zip",
)

Copy link
Contributor Author

@tingilee tingilee Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rule seems redundant so deleting here. I had to delete this otherwise I get errors:

Error in fail: generate_repo_config: generate_repo_config: /workdir/WORKSPACE: multiple rules have the name "python_2023_1"

See CI build failure: https://buildkite.com/bazel/intellij-plugin-aspect/builds/20467

Here are the duplicated rules:

intellij/WORKSPACE

Lines 320 to 336 in ae7424b

http_archive(
name = "python_2023_1",
build_file_content = _PYTHON_CE_BUILD_FILE,
sha256 = PYTHON_PLUGIN_231_SHA,
url = PYTHON_PLUGIN_231_URL,
)
PYTHON_PLUGIN_232_URL = "https://plugins.jetbrains.com/maven/com/jetbrains/plugins/PythonCore/232.10203.2/PythonCore-232.10203.2.zip"
PYTHON_PLUGIN_232_SHA = "027bc9e2322f21cb3093b3254035cfeaac587552f9db2f664b28280f172acfed"
http_archive(
name = "python_2023_2",
build_file_content = _PYTHON_CE_BUILD_FILE,
sha256 = PYTHON_PLUGIN_232_SHA,
url = PYTHON_PLUGIN_232_URL,
)

@tingilee
Copy link
Contributor Author

tingilee commented Nov 9, 2023

Hi! Thanks @tingilee for your contribution. Could you please write a test for this?

Added tests and also include dependencies needed in the WORKSPACE.

@agluszak agluszak self-assigned this Nov 10, 2023
@agluszak
Copy link
Collaborator

LGTM, but there's a conflict.

@tpasternak want to have a final look?
@mai93 what's the policy for introducing new dependencies to WORKSPACE?

@tpasternak
Copy link
Collaborator

@tpasternak want to have a final look?
So I just don't fully understand why it is required to add all the dependencies to the WORKSPACE file. How do we use them?

@tingilee
Copy link
Contributor Author

tingilee commented Nov 14, 2023

@tpasternak

So I just don't fully understand why it is required to add all the dependencies to the WORKSPACE file. How do we use them?

These dependencies where added similarly to

intellij/WORKSPACE

Lines 865 to 881 in f49aaf2

# Dependency needed for kotlin coroutines library
jvm_maven_import_external(
name = "kotlinx_coroutines",
artifact = "org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.6.2",
artifact_sha256 = "09aac136027678db2d3c2696696202719af9213ba17ae076f4c4421008885bcb",
licenses = ["notice"], # Apache 2.0
server_urls = ["https://repo1.maven.org/maven2"],
)
# Dependency needed for kotlin coroutines test library
jvm_maven_import_external(
name = "kotlinx_coroutines_test",
artifact = "org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm:1.6.2",
artifact_sha256 = "6eb5c29f60fcacde882b1d393bf9a2fe9535bece1c707396fdbd755559dc043d",
licenses = ["notice"], # Apache 2.0
server_urls = ["https://repo1.maven.org/maven2"],
)
. Previously, there was no tests for Bazel + Go integration in IntelliJ. To address the PR comments, I've added tests for Bazel + Go integrations, which means we need the golang dependencies, specifically all of the dependencies to support aspect/testing/tests/src/com/google/idea/blaze/aspect/go/go_proto_library/BUILD

Copy link
Collaborator

@blorente blorente left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tingilee I think what @tpasternak meant was that we don't reference those dependencies anywhere in the BUILD files, so it's unclear how they are needed for the tests. For instance, I'd expect to see @org_golang_x_net somewhere in the test build file.

@@ -0,0 +1,4 @@
def setup_tests():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what this file is for, it doesn't seem to be referenced anywhere.

@@ -0,0 +1 @@
package simple
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with this file, it doesn't seem to be referenced.

@blorente
Copy link
Collaborator

@tingilee I've rebased this PR and addressed the comments on this branch: https://github.com/blorente/intellij/tree/blorente/address-comments. Should be ready to merge.

If you're okay with it, feel free to rebase this PR on top of mine. Or I can just merge my version if you're busy, whatever works. This functionality would be very useful for us.

@blorente
Copy link
Collaborator

blorente commented Feb 5, 2024

@tpasternak @mai93 , would you be okay if I open a PR with the cleanups and we merge this? Some of our users really liked the feature, and it seems generally useful.

@tpasternak
Copy link
Collaborator

@tpasternak @mai93 , would you be okay if I open a PR with the cleanups and we merge this? Some of our users really liked the feature, and it seems generally useful.

Why would I have anything against it? 😅 Are there any disadvantages?

@blorente
Copy link
Collaborator

blorente commented Feb 6, 2024

@tingilee I opened a PR with the cleanup here: #6030
Please let us know in a couple of days if you'd like to incorporate the changes to yours, otherwise we'll merge it.

@ramilmsh
Copy link

ramilmsh commented Feb 6, 2024

@blorente Hi!

I've tried out our plugin version and unfortunately it doesn't seem to solve

#5538

Specifically, If an embedded proto library depends on an embedded proto library, resolution still fails. I have not yet had the time to create a more complex use-case in my demo repo, which I will try to do this week, but I'd be happy to demonstrate the problem. I'm also not against contributing a fix myself, but I have no idea how intellij works and how the plugin is structured, so it would take me really-really long to do so.

@blorente
Copy link
Collaborator

@ramilmsh I've tried to reproduce the case you mention in https://github.com/blorente/intellij/blob/blorente/repro-oss-issue-with-proto-in-proto/examples/go/with_proto/proto/BUILD.bazel, and haven't been able to.
Since this PR, though it may be incomplete, is useful on its own, I'd like to merge it soon. Let's hop over to the issue you opened to discuss if it's missing some features, and how to implement them.

@blorente
Copy link
Collaborator

Closing since #6030 merged.

@blorente blorente closed this Mar 19, 2024
@github-actions github-actions bot removed the awaiting-review Awaiting review from Bazel team on PRs label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: GoLand GoLand plugin
Projects
Development

Successfully merging this pull request may close these issues.

Embedded go_proto_library not being indexed
5 participants